<!DOCTYPE html>
<html>

<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">

<title>素材火www.sucaihuo.com - 数据表格</title>
<meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
<meta name="description"
  content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

<link href="css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<!-- Data Tables -->
<link href="css/plugins/dataTables/dataTables.bootstrap.css"
  rel="stylesheet">

<link href="css/animate.css" rel="stylesheet">
<link href="css/style.css?v=2.2.0" rel="stylesheet">
</head>

<body class="top-navigation">
<div id="wrapper">
    <div id="page-wrapper" class="gray-bg dashbard-1">
      <div class="row border-bottom">
        <nav class="navbar navbar-static-top" data-role="navigation" style="margin-bottom:0">
          <div class="navbar-header">
            <div class="minimalize-styl-2">
             
              
            
                  <a class="btn btn-success" title="返回主页" href="main.html"><i class="fa fa-lg fa-home"></i></a>
              <a class="back-link btn btn-success" title="后退"><i class="fa fa-lg fa-arrow-left"></i></a>
              <a class="reload-link btn btn-success" title="重新加载"><i class="fa fa-lg fa-repeat"></i></a>
              <!-- 配置点1 -->
              <!-- 上下文导航 -->
              <ol id="guide" class="breadcrumb m-l">
                <li><a>配送中心管理</a></li>
                <li><a>进货管理</a></li> 
                <li><strong>进货管理</strong></li>
              </ol>
              
              
            </div>
          </div>
          <div class="nav navbar-top-links navbar-right minimalize-styl-2">
            <span class="m-r-sm text-muted welcome-message btn btn-link">欢迎使用Feces物流管理系统</span>
          </div>
        </nav>
      </div>
      
      
      <!-- 配置点2 -->
      <!-- 内容 -->
      <div class="wrapper wrapper-content animated fadeInRight">
      
      <div class="row">
        <div class="col-lg-12">
          <div class="ibox float-e-margins">
            <div class="ibox-content">  
              <button class="btn btn-primary btn-xm" onclick="doGet();">缺货检查</button>
            <button type="button" onclick="doPost();"class="btn btn-primary btn-xm">提交</button>          
              <table class="table table-striped table-bordered table-hover "
                id="editable">
                <thead>
                  <tr>
                                            <th>商品ID</th>
                                            <th>现有库存量</th>
                                            <th>安全库存量</th>
                                            <th>缺货数量</th>
                                            <th>进货量</th>
                  </tr>
                </thead>
                <tbody>

                </tbody>
              </table>

            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>


  <!-- Mainly scripts -->
  <script src="js/jquery-2.1.1.min.js"></script>
  <script src="js/bootstrap.min.js?v=3.4.0"></script>
  <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
  <script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>

  <script src="js/plugins/jeditable/jquery.jeditable.js"></script>

  <!-- Data Tables -->
  <script src="js/plugins/dataTables/jquery.dataTables.js"></script>
  <script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>

  <!-- Custom and plugin javascript -->
  <script src="js/hplus.js?v=2.2.0"></script>
  <script src="js/plugins/pace/pace.min.js"></script>
  <!-- Page-Level Scripts -->
  <script>
    var url_0 = "api/storehouses";
    var url_1 = "api/StorehouseProServlet";
    var url_2="api/PurchaseOrderServlet";
    var xlist=[];
    $(document).ready(function() {
      $('.dataTables-example').dataTable();

      /* Init DataTables */
      var oTable = $('#editable').dataTable();

      /* Apply the jEditable handlers to the table */
      oTable.$('td').editable('../example_ajax.php', {
        "callback" : function(sValue, y) {
          var aPos = oTable.fnGetPosition(this);
          oTable.fnUpdate(sValue, aPos[0], aPos[1]);
        },
        "submitdata" : function(value, settings) {
          return {
            "row_id" : this.parentNode.getAttribute('id'),
            "column" : oTable.fnGetPosition(this)[2]
          };
        },

        "width" : "90%",
        "height" : "100%"
      });

    });
   function doGet() {
        var id = 81;
        $.ajax({
          type : "GET",
          url : url_1,
          data :{
            storehouseId : id,
          },
          success: function(res){
            var re=res.data;
            var rel=re;
            var len=rel.length;
            for(var i=0;i<len;i++){
              var rr=rel[i];
              var y=rr.critical;
              var x=rr.quantity;
              var z=rr.critical-rr.quantity;
              if(x<y){ 
              $('#editable').dataTable()
          .fnAddData(
            [ rr.productId,rr.quantity,rr.critical,z,z]);
          
          var x_1= {"product_id":rr.productId, "need_quantity":z,"real_quantity":z};
          xlist.push(x_1);
          }

          }

        }


        });


        }
      

    

    function doPost(){
      console.log(xlist);
      var date ="2015-09-01";
      var is =0;
        $.ajax({
            type : "post",
            url : url_2,
            data : {
              date : date,
              finish : is,
              "pro_list" : JSON.stringify(xlist),
            },
            // datatype : 'json',
            success: function(result){
              }



          });
    }
    </script>
  <script type="text/javascript"
    src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
  <!--统计代码，可删除-->

</body>

</html>
